package com.lagou.edu.service;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Component;

import java.util.concurrent.ThreadLocalRandom;

@Component
public class ConsumerComponent {

    @Reference(check = false)
    private DemoService demoService;

    public String getDemoIp() {
        return demoService.getDemoIp();
    }

    public String randomMethod() throws InterruptedException {
        int i = ThreadLocalRandom.current().nextInt(4);
        switch (i) {
            case 1:
                return demoService.methodA();
            case 2:
                return demoService.methodB();
            case 3:
                return demoService.methodC();
            default:
                return demoService.methodA();
        }
    }
}
